package com.ybt.service.impl.pack.unpack;

import com.ruleengine.context.IContextProperty;
import com.ruleengine.context.IWorkflowConext;
import com.ruleengine.context.impl.ContextPropertyFactory;
import com.ruleengine.endpoint.data.IEndpointData;
import com.ybt.context.IYBTContextConstants;
import com.ybt.service.exception.ServiceException;
import com.ybt.service.impl.BlockingBaseService;

public class CcbUnpack extends BlockingBaseService {

    @Override
    public void service(IWorkflowConext context, IEndpointData data)
            throws ServiceException {
        // TODO Auto-generated method stub
        IContextProperty<String> op = context
                .getContextProperty(IYBTContextConstants.ORIGINAL_DATA);
        //交易报文体
        String body = op.getValue().substring(8);
        data.setInData(body);

        // 外部交易码
        String fun = op.getValue().substring(4, 8);
        IContextProperty<String> tranPro = ContextPropertyFactory.getInstance()
                .createPublicVariable(IYBTContextConstants.OUT_TRANCODE);
        tranPro.setValue(fun);
        context.setContextProperty(tranPro);

    }

}
